from fastapi import HTTPException, status

class BusinessError(HTTPException):
    """业务异常基类"""
    def __init__(self, detail: str, code: int = status.HTTP_400_BAD_REQUEST):
        super().__init__(status_code=code, detail=detail)

class ResourceNotFound(BusinessError):
    """资源未找到异常"""
    def __init__(self, detail: str):
        super().__init__(detail=detail, code=status.HTTP_404_NOT_FOUND)

class StockError(BusinessError):
    """库存相关异常"""
    def __init__(self, detail: str):
        super().__init__(detail=detail, code=status.HTTP_400_BAD_REQUEST) 